package com.vlin.converter.defaut;

import org.json.JSONObject;

import com.vlin.converter.DeviceInfoConverter;
import com.vlin.entity.mode.DeviceMode;

public abstract class AbstractDeviceInfoConverter implements DeviceInfoConverter {

	
	@Override
	public JSONObject convertToFront(JSONObject params, DeviceMode deviceMode) {
		
		if(!supportDeviceType(deviceMode)) {
			return new JSONObject();
		}
		return doConvertToFront(params);
	}
	
	abstract public JSONObject doConvertToFront(JSONObject params);

	@Override
	public JSONObject convertToBack(JSONObject params, DeviceMode deviceMode) {

		if(!supportDeviceType(deviceMode)) {
			return new JSONObject();
		}
		return doConvertToBack(params);
	}
	
	abstract public JSONObject doConvertToBack(JSONObject params);

	@Override
	public boolean supportDeviceType(DeviceMode deviceMode) {

		if(deviceMode == null )
			return false;
		return doSupport(deviceMode);
	}
	
	abstract public boolean doSupport(DeviceMode deviceMode);

}
